//基础样式
import './assets/style/base.scss';
import dayjs from 'dayjs';
import * as _ from 'lodash-es';
import App from './App.vue';
import { createVersionPolling } from 'version-polling';
//routes
import router from './route/index';
//自定义指令
import directive from './directives/index.ts';
//自定义插件
import plugins from './plugins/index';
//pinia

import piniaPersist from 'pinia-plugin-persist';
declare global {
    interface Window {
        dayjs: typeof dayjs;
    }
}
declare global {
    interface Window {
        _: typeof _;
    }
}
window.dayjs = dayjs;
window._ = _;
createVersionPolling({
    appETagKey: '__APP_ETAG__',
    pollingInterval: 5 * 1000, // 单位为毫秒
    silent: process.env.NODE_ENV === 'development', // 开发环境下不检测
    onUpdate: (self) => {
        // 当检测到有新版本时，执行的回调函数，可以在这里提示用户刷新页面
        const result = confirm('页面有更新，点击确定刷新页面！');
        if (result) {
            self.onRefresh();
        } else {
            self.onCancel();
        }
    }
});
const pinia = createPinia();
pinia.use(piniaPersist); //持久化存储
const app = createApp(App);
directive(app);
app.use(pinia).use(router).use(plugins).mount('#app');
